package com.example.h9iserver.service.springAi;

import com.example.h9iserver.domain.User;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.messages.Message;
import org.springframework.ai.chat.messages.SystemMessage;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.model.ChatResponse;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

// 取消注释即可在 SpringBoot 项目启动时执行
@Component
@RequiredArgsConstructor
@Slf4j
public class OllamaAiInvoke {

    private final ChatModel chatModel;

    public void chatModelService() {
        // 基础用法(ChatModel)
        ChatResponse chatResponse = chatModel.call(new Prompt("你好"));

        // 高级用法(ChatClient)
        ChatClient chatClient = ChatClient.builder(chatModel).defaultSystem("你是恋爱顾问").build();

        String chatResult = chatClient.prompt().user("你好").call().content();

    }
}
